<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 <link rel="stylesheet" href="model.css" />

     <?php include("head.php"); ?>
 <?php include("entete.php"); ?>
   <?php include("menu.php"); ?>
<?php



try{
  $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
  $bdd = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_DATABASE, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, $pdo_options);
  
  //récupération de la variable d'URL,
  //qui va nous permettre de savoir quel enregistrement modifier
  $id  = $_GET["idAssociation"] ;
  
  //requête SQL:
  
  $sql = 'SELECT *
            FROM ASSOCIATION 
	    WHERE ASSOCIATION.ID_ASSOC = '.$id;
  
  
  $reponse = $bdd->query($sql);
  
  
  
  //affichage des données:
  if( $donnees = $reponse->fetch() )
    { 
      ?>
      <form action="modif2_assoc.php" method="POST">
	<input type="hidden" name="id" value="<?php echo($id) ;?>">
	<table border="0" align="center" cellspacing="2" cellpadding="2">   
	<input type="hidden" name="nom" value="<?php echo($donnees['NOM_ASSOC']) ; ?>">
	<tr align="center">
	<td>objectif</td>
	<td><textarea name="objectif" rows="8" cols="45"><?php echo $donnees['OBJECTIF']; ?>
	</textarea></td>
	    </tr>
	    <tr align="center">
	    <td>cotisation</td> 
	    <td><input type="text" name="cotisation" value="<?php echo($donnees['COTISATION']); ?>"></td>
	    </tr>
 <?php 	    
	    }

      
$reponse->closeCursor();    
/*  $sql = 'SELECT DISTINCT * FROM FINANCEMENT, SOURCE WHERE FINANCEMENT.ID_SOURCE = SOURCE.ID_SOURCE 
AND FINANCEMENT.ID_ASSOC = '.$id;  
  
  $reponse  = $bdd->query($sql);
  $i = 0;
  while( $donnees = $reponse->fetch() ){
    ?>
    <tr align="center">
      <td>montant</td>
      <td><input type="text" name="montant <?php echo $i; ?>" value="<?php echo($donnees['MONTANT']); ?>"></td>
      </tr>
      
      <tr align="center">
      <td>financement</td>
      <td><input type="text" name="source <?php echo $i; ?>" value="<?php echo($donnees['DONATEUR']); ?>"></td>
      </tr>
*/
 
 
 ?>
  
  <tr align="center">
     <td colspan="2"><input type="submit" value="Modifier"></td>
     </tr>
     </table>
     </form>
     <?php
     
     $reponse->closeCursor(); 
}
catch (Exception $e)
{
  die('Erreur : ' . $e->getMessage());
} 
?>

 <?php include("pied_de_page.php"); ?>